package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_extend_channel")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.ExtendChannelMapper")
public class ExtendChannelDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 机构主键id
     */
    @TableField(value = "org_id")
    private Long orgId;

    /**
     * 推广渠道编码
     */
    @TableField(value = "channel_code")
    private String channelCode;

    /**
     * 推广渠道名称
     */
    @TableField(value = "channel_name")
    private String channelName;

    /**
     * 推广渠道联系人
     */
    @TableField(value = "linkman_name")
    private String linkmanName;

    /**
     * 推广渠道联系电话
     */
    @TableField(value = "linkman_mobile")
    private String linkmanMobile;

    /**
     * 撮合单价
     */
    @TableField(value = "unit_price")
    private Long unitPrice;

    /**
     * 备注说明
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 邀请码8位：配合交易中心推送信息关联
     */
    @TableField(value = "invite_code")
    private String inviteCode;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    public ExtendChannelVo buildVo() {
        return new ExtendChannelVo(id, orgId, channelCode, channelName, linkmanName, linkmanMobile, unitPrice, remark, inviteCode, gmtCreate, gmtModified, userCreate, userModified);
    }

    public static ExtendChannelDO of(ExtendChannelVo vo) {
        return new ExtendChannelDO(vo.getId(), vo.getOrgId(), vo.getChannelCode(), vo.getChannelName(), vo.getLinkmanName(), vo.getLinkmanMobile(), vo.getUnitPrice(), vo.getRemark(), vo.getInviteCode(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified());
    }
}
